﻿using GasFee;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TestProject1
{
    
    
    /// <summary>
    ///This is a test class for GasPriceConventerTest and is intended
    ///to contain all GasPriceConventerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class GasPriceConventerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetLitePerOneHundradKilometerFromMpg
        ///</summary>
        [TestMethod()]
        public void GetLitePerOneHundradKilometerFromMpgTest()
        {
            var target = new GasPriceConventer(); 
            double mpg = 26.0; 
            double expected = 9.046;
            double actual;
            actual = target.GetLiterPerOneHundradKilometerFromMpg(mpg);
            Assert.IsTrue(Math.Abs(expected-actual) < 0.01);
        }

        /// <summary>
        ///A test for GetMpgFromLiterPerOneHundradKilometer
        ///</summary>
        [TestMethod()]
        public void GetMpgFromLiterPerOneHundradKilometerTest()
        {
            var target = new GasPriceConventer(); 
            double literPerHundradKilometer = 9.046F; 
            double expected = 26.0F; 
            double actual;
            actual = target.GetMpgFromLiterPerOneHundradKilometer(literPerHundradKilometer);
            Assert.IsTrue(Math.Abs(expected - actual) < 0.01);
        }

        /// <summary>
        ///A test for GetBeijingPriceFromUsaPrice
        ///</summary>
        [TestMethod()]
        public void GetBeijingPriceFromUsaPriceTest()
        {
            var target = new GasPriceConventer(); 
            double regularPerGallonPrice = 4.0F; 
            double expected = 6.657F; 
            double actual;
            actual = target.GetBeijingPriceFromUsaPrice(regularPerGallonPrice);
            Assert.IsTrue(Math.Abs(expected - actual) < 0.01);
        }

        /// <summary>
        ///A test for GetUsaPriceFromBeijingPrice
        ///</summary>
        [TestMethod()]
        public void GetUsaPriceFromBeijingPriceTest()
        {
            var target = new GasPriceConventer(); 
            double beijingPrice = 7.64F; 
            double expected = 4.59F; 
            double actual;
            actual = target.GetUsaPriceFromBeijingPrice(beijingPrice);
            Assert.IsTrue(Math.Abs(expected - actual) < 0.01);
        }
    }
}
